function [Moment_Mat,Mean_Mat,Prob_Vec]=QW2Moment(QW_Mat,QQ_Unit,OrderTable)

MultiNum    =   size(QW_Mat,2);
QQNum       =   size(QQ_Unit,2);
MomNum      =   size(OrderTable,1);
Moment_Mat  =   zeros(MomNum,MultiNum);
Mean_Mat    =   zeros(QQNum,MultiNum);
Prob_Mat    =   zeros(1,MultiNum);
for i=1:MultiNum
    [CentMoment,Mean,TotalProb] ...
            =   EmpiricalMoment(QQ_Unit,QW_Mat(:,i),OrderTable);
    Moment_Mat(:,i) ...
            =   CentMoment;
    Mean_Mat(:,i) ...
            =   Mean';
    Prob_Mat(:,i) ...
            =   TotalProb; 
end

% Moment_Vec  =   reshape(Moment_Mat,[MomNum*MultiNum,1]);
Prob_Vec    =   reshape(Prob_Mat,[MultiNum,1]);

return

function [CentMoment,Mean,TotalProb]=EmpiricalMoment(QQ,QW,OrderTable)

QQ_Dim          =   size(QQ,2);
QQ_Num          =   size(QQ,1);
Moment_Num      =   size(OrderTable,1);

TotalProb       =   sum(QW,1);
ConditionalDist =   bsxfun(@rdivide,QW,TotalProb);

Mean            =   QQ'*ConditionalDist;

MaxOrder        =   max(max(OrderTable));
UnitCentMoment  =   zeros(QQ_Num,MaxOrder+1,QQ_Dim);
CentQQ          =   bsxfun(@minus,QQ,Mean');
for i=1:QQ_Dim
    UnitCentMoment(:,:,i)   =   bsxfun(@power,CentQQ(:,i),(0:MaxOrder));
end

CentMomentTable =   ones(QQ_Num,Moment_Num);
for i=1:Moment_Num
    for j=1:QQ_Dim
        Order_Temp      =   OrderTable(i,j)+1;
        CentMomentTable(:,i) ...
                        =   CentMomentTable(:,i).* ...
                            UnitCentMoment(:,Order_Temp,j);
    end
end

CentMoment      =   CentMomentTable'*ConditionalDist;



return